<!DOCTYPE HTML>
<html class="x-admin-sm" lang="en-US" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎</title>
    <th:block th:include="include::header"/>
</head>
<body>

<div class="layui-form-item">
    <input type="hidden" id="id" name="id" th:value="${equip.getId()}" required="" lay-verify="">
    <button class="layui-btn" onclick="edit()">提交
    </button>
</div>

<!--实际应用-->
<div id="summernote"></div>


<script th:inline="javascript" type="text/javascript">

    // 初始化富文本
    $(document).ready(function () {
        $('#summernote').summernote();
    });
    //赋值
    var intro = [[${equip.getIntro()}]];
    $('#summernote').summernote('code', intro);

    //发送数据
    function edit() {
        //取值
        console.log($('#summernote').summernote('code'));
        console.log(id.value);
        $.ajax({
            url: "/equip/edit",
            type: "POST",
            data: {
                id: id.value,
                intro: $('#summernote').summernote('code'),
            },
            success(res) {
                if (res.success) {
                    layer.msg("修改成功", {
                            icon: 6,
                            time: 500
                        },
                        function () {
                            //关闭当前frame
                            xadmin.close();
                        });
                } else {
                    layer.msg(res.msg)
                }
            }
        })
    }
</script>
</body>
</html>
